/**
 * This library is a thing to realize D2L and DI and AOP on Flex2(ActionScript3).
 * Copyright (C) 2007 Takamasa Seki
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * Contributor : Takamasa Seki(takanafu@gmail.com)
 *               http://www.takanafu.com/
 */

package com.takanafu.haruframework{
	import com.takanafu.core.haru_internal;
	
	import flash.events.Event;
	
	import mx.core.Application;
	import mx.core.UIComponentDescriptor;
	import mx.core.mx_internal;
	import mx.core.Singleton;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;
	import flash.utils.ByteArray;
	import com.takanafu.haruframework.d2l.invoker.IInvocationProxy;
	import com.takanafu.haruframework.d2l.HaRu;
	
	use namespace haru_internal;
	use namespace mx_internal;

	[Frame(factoryClass="com.takanafu.haruframework.d2l.HaRuSystemManager")]
	public class HaRuApplication extends Application{
		[Inspectable(defaultValue="ApplicationContext.xml")]
	    public var appContextURL:String = "ApplicationContext.xml";
    
		public function HaRuApplication(){
			super();
			HaRu.registApplicationDelegate(this);
		}
		
		override public function initialize():void{
			trace("[HaRu] Complete HaRuFramework initialization!");
			super.initialize();
			
		}

		override mx_internal function setDocumentDescriptor(desc:UIComponentDescriptor):void{
			var ary:Array = new Array();

			ary.push(this.id);
			desc.document = this;
			HaRu.registDelegateDesc(desc,ary);
			
			super.setDocumentDescriptor(desc);
		}
		
		final public function relayInvocationHandler(event:*):void{
			var ivc:IInvocationProxy = Singleton.getInstance("com.takanafu.haruframework.d2l.invoker::IInvocationProxy") as IInvocationProxy;
			
			ivc.relayInvocationHandler(event);
		}
	}
}